package com.fy.oa.zc.groovy.manager;

import java.util.Map;

public class QueryResultManager {
//	private QueryResultBean head = new QueryResultBean();
	
//	public QueryResultBean
}

class QueryResultBean {
	private QueryResultBean ahead;
	private QueryResultBean behind;
	private Map<String, Object> value;
	
	public QueryResultBean getAhead() {
		return ahead;
	}

	public void setAhead(QueryResultBean ahead) {
		this.ahead = ahead;
	}

	public QueryResultBean getBehind() {
		return behind;
	}

	public void setBehind(QueryResultBean behind) {
		this.behind = behind;
	}

	public Map<String, Object> getValue() {
		return value;
	}

	public void setValue(Map<String, Object> value) {
		this.value = value;
	}

	public void insert(QueryResultBean queryResultBean) {
		if (queryResultBean != null) {
			synchronized (QueryResultBean.class) {
				if (queryResultBean != null) {
					queryResultBean.behind = this.behind;
					this.behind = queryResultBean;
					queryResultBean.ahead = this;
					ClearTimer timer = new ClearTimer();
					timer.setQueryResultBean(queryResultBean);
					new Thread(timer).start();
				}
			}
		}
	}

	class ClearTimer implements Runnable {
		private QueryResultBean queryResultBean;

		public void setQueryResultBean(QueryResultBean queryResultBean) {
			this.queryResultBean = queryResultBean;
		}

		@Override
		public void run() {
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			if (queryResultBean != null) {
				synchronized (QueryResultBean.class) {
					if (queryResultBean != null) {
						queryResultBean.getAhead().setBehind(queryResultBean.getBehind());
						queryResultBean = null;
					}
				}
			}
		}
	}

}
